<template>
  <div>
    <el-table
      :data="newsList"
      :stripe="true"
      style="width: 100%">
      <el-table-column
        prop="id"
        label="编号"
        min-width="30%">
      </el-table-column>
      <el-table-column
        prop="biaoti"
        label="新闻标题">
      </el-table-column>
      <el-table-column
        prop="danwei"
        label="单位">
      </el-table-column>
      <el-table-column
        label="操作">
        <template slot-scope="scope">
          <el-button type="danger" @click="deleteaa(scope.row.id)">删除</el-button>
          <el-button type="primary" @click="updateaa(scope.row.id)">修改</el-button>
        </template>
      </el-table-column>
    </el-table>
    <router-view/>
    <br>
    <el-button type="primary" @click="addaa">发布新闻</el-button>
  </div>
</template>

<script>
export default {
  name: "newsList",
  data(){
    return {
      newsList:[],
      cid:""
    }
  },
  created(){
    this.cid=this.$route.query.cid;
    this.selectAll();
  },
  methods: {
    deleteaa(id){
      this.$confirm("是否确认删除","删除提示").then(()=>{
        this.axios.delete("/huisheng/delete/"+id).then((resp)=>{
          this.$message.success("删除成功！");
          this.selectAll();
        });
      });
    },
    updateaa(id){
      this.$router.push({path:"UpdateHuisheng",query:{id:id}})
    },
    addaa(){
      this.$router.push({path:"AddHuisheng"})
    },
    selectAll(){
      let url="";
      url="/huisheng/"
      this.axios.get(url).then((resp)=>{
        this.newsList=resp.data;
      });
    }
  }
}
</script>

<style scoped>

</style>
